#!coding:utf-8
import requests
import json
import pytest
def operationJson():
    """对login.json文件进行处理"""
    return json.load(open('22.json', 'r', encoding='utf-8'))['item']

@pytest.mark.parametrize('datas', operationJson())
def test_api_login(datas):
    """登录API的校验测试"""
    # print(type(datas['response']))
    r = requests.request(
        method=datas['request']['method'],
        url=datas['request']['url']['raw'],
        json=json.loads(datas['request']['body']['raw']))
    assert r.json() == datas['response']


if __name__ == '__main__':
    pytest.main(["-s", "-v", "11.py"])
